<%@page contentType="text/html; charset=utf-8" %>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/messages.jsp"%>
<%@ include file="/commons/commonEdit.jsp" %>
<%@ include file="/commons/validation.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="JavaScript"  src="${ctx}/scripts/div/common.js"></script>
<script language="javaScript" type="text/javascript" src="${ctx}/pages/com/ce/pms/charge/chargeStandard/sectionCharge.js"></script>
<title></title>
<script>
var closeFlag= null;
var flag = null;
var sourceValue = null;
var divListObj = null;
function ajaxSubmit(){
	$('sectionStardStr').value = divListObj.getResult();
	setSelectCodeToHidden('scountParameter','countParameter');
	setSelectCodeToHidden('scountMode','countMode');
	setRadioValueToHidden('rlatefeeSelect','latefeeSelect');
	var isTrue=$('standardForm').fireEvent("onSubmit");
    if(isTrue){
    	var newValue=$('standardForm').serialize();
		if(sourceValue==newValue){
			return false;
		}
		else
		{
    	if(flag == "add")
         	var url = "${ctx}/charge_chargeStandardAction.do?method=addGeneralStandard";
        else if(flag == "update")
            var url = "${ctx}/charge_chargeStandardAction.do?method=editGeneralStandard";
        var param = Form.serialize('standardForm');
        new Ajax.Request(url,{method: 'post',parameters :param ,onSuccess : showResponse});
        }
	}
}
function showResponse(response){
	if('true' == response.responseText){
	    var obj=findFrame('chargeItemMainFrame');
		obj.freshStandardList();
    }
    ajaxSubmitException(response.responseText);
	if(!closeFlag){ //点击的保存按钮
        windowClose();
	}
	else {  //点击的保存并新增
        location.reload();
	}
}
function setCloseFlag(flag){
	closeFlag = flag;
}
function next(url){
	window.location.href = url;
}
function closeWin(){
	var newValue=$('standardForm').serialize();
	if(sourceValue==newValue){
		windowClose();
	}else{
		var result=confirm("是否要保存并退出？");
		//AlarmConfirm('是否要保存并退出？',"main","ajaxSubmit");
		if(result){
			ajaxSubmit();
			return;
		}else{
			windowClose();
		}
	}
}

</script>

</head>

<body onload="init('${editFlag}','${chargeItemType}')">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="${ctx}/images/ico_Advance.gif" width="16" height="16" align="absmiddle"> <span class="window_head_intext" id="item_title"></span></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td class="aux_header_line_2"></td>
  </tr>
  <tr>
    <td class="content"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="aux_outtable_color"><div style="height:350px;overflow:auto;">
        <form name="standardForm" method="post" action="" class="required-validate">
        <input type="hidden" name="chargeItemId" value="${chargeStandard.chargeItemId}">
		<input type="hidden" name="currentVersionId" value="${chargeStandard.currentVersionId}">
        <input type="hidden" id="keyword" name="keyword" value="${chargeStandard.keyword}">
		<table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color">
          <tr>
            <td colspan="4" class="aux_titletable">${key.standardTitle}</td>
            </tr>
          <tr>
            <td class="aux_intable_td1">${key.chargeItemName}：</td>
            <td class="aux_intable_td2">${chargeStandard.chargeItemName}
            </td>
            <td class="aux_intable_td1">${key.staName}：</td>
            <td class="aux_intable_require">
            <input name="staName" type="text" class="required validate-char validate-ajax" relativeId="keyword" validateUrl="" value="${chargeStandard.staName}" size="16">
            </td>
          </tr>
          <tr>
            <td colspan="4" class="aux_titletable">${key.usedifine}</td>
          </tr>
          <tr>
                <td class="aux_intable_td1">${key.countparament}：</td>
                <td class=" aux_intable_require">
                	<mypms:Sysrefcode  name="scountParameter"
              					 showTip="true"
              					 code="FEE_STA_VERSION_COUNT_PARAMETER"
              					 style="width:110px"
              					 onchange=""
              					 className="select-one-required"
              					 >
              		</mypms:Sysrefcode>
              		<input type="hidden" name="countParameter" value="${chargeStandardVersion.countParameter}">
                </td>
                <td class=" aux_intable_td1">&nbsp;</td>
                <td class="aux_intable_td2">&nbsp;</td>
            </tr>
            <tr>
                <td width="19%" class="aux_intable_td1">${key.countmode}：</td>
                <td width="31%" class="aux_intable_require">
                	<mypms:Sysrefcode  name="scountMode"
                				 id="scountMode"
              					 showTip="true"
              					 code="FEE_STA_VERSION_COUNT_MODE"
              					 style="width:110px"
              					 onchange=""
              					 className="select-one-required"
              					 >
              		</mypms:Sysrefcode>
              		<input type="hidden" name="countMode" value="${chargeStandardVersion.countMode}">
				</td>
                <td width="19%" class="aux_intable_td1">&nbsp;</td>
                <td width="31%" class="aux_intable_td2">&nbsp;</td>
             </tr>
             <tbody id="layer1">
			 </tbody>
			 <input type="hidden" name="sectionStardStr" value="">
            <tr>
               <td colspan="4" class="aux_titletable">${key.latefee}</td>
            </tr>
            <tr>
	            <td class="aux_intable_td1">${key.latefeeSelect}：</td>
	            <td colspan="3" class="aux_intable_require">
	            <input type="radio"  name="rlatefeeSelect" value="1" class="validate-one-required" onclick="setRadioRelation(this,'rate')">${key.yes}
	  			<input type="radio"  name="rlatefeeSelect" value="0" class="validate-one-required" onclick="setRadioRelation(this,'rate')">${key.no}
	  			<input type="hidden" name="latefeeSelect" value="${chargeStandardVersion.latefeeSelect}">
	  			</td>
            </tr>
            <tr>
	            <td class="aux_intable_td1">${key.cmode}：</td>
	            <td colspan="3" class="aux_intable_td2">
	              ${key.byday}：
	              <input name="rate" type="text" maxlength="8" class="" value="${chargeStandardVersion.rate}" size="6" afterInsert="showratetip">
	              %<span id="showratetip"></span></td>
           </tr>
        </table>
        </form>
		</div></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td class="window_footer"><table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><table border="0" cellpadding="0" cellspacing="0" id="item_submitAgain">
            <tr>
              <td class="buttonOffLeft" id="btn1_41"></td>
              <td class="buttonOffMiddle" id="btn1_42" onClick="setCloseFlag(true);ajaxSubmit('standardForm');" onMouseOver="btn_change_over(4)" onMouseOut="btn_change_out(4)" onblur="btn_change(4)"><img src="${ctx}/images/ico_saveandnewfile.gif" alt="" width="14" height="14" border="0" align="absbottom"> ${key.saveAndAdd}</td>
              <td class="buttonOffRight" id="btn1_43"></td>
            </tr>
        </table></td>
        <td class="btn_between_space"></td>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_21"></td>
              <td class="buttonOffMiddle" id="btn1_22" onClick="setCloseFlag(false);ajaxSubmit('standardForm');" onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)" onblur="btn_change(2)"><img src="${ctx}/images/ico_ok.gif" alt="" width="14" height="14" border="0" align="absbottom"> ${key.save}</td>
              <td class="buttonOffRight" id="btn1_23"></td>
            </tr>
        </table></td>
        <td class="btn_between_space"></td>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_31"></td>
              <td class="buttonOffMiddle" id="btn1_32" onClick="windowClose();" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)" onblur="btn_change(3)"><img src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14" border="0" align="absbottom"> ${key.close}</td>
              <td class="buttonOffRight" id="btn1_33"></td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
<script defer>
function init(editFlag,chargeItemType){
	if(editFlag == 'add'){//add
	    divListObj = new sectionChargeObj("scountMode","layer1",chargeItemType);
		divListObj.initTbody();
		$('item_title').innerText =  "${key.addGeneral}";
		$('item_submitAgain').style.display="";
		flag = "add";
	}else if(editFlag == 'update'){//update
		showSelectValue('scountParameter','countParameter');
		showSelectValue('scountMode','countMode');
		showRadioCheckedValue('rlatefeeSelect','latefeeSelect');
		if($('latefeeSelect').value=="1"){
			Validation.changeElmValidate('rate',"required float-right integer-decimal-range-8-2");
		}else{
			$('rate').setAttribute("readOnly",true);
		}
	    divListObj = new sectionChargeObj("scountMode","layer1",chargeItemType,"${chargeStandardVersion.sectionStardStr}");
		divListObj.initTbody();
		$('item_title').innerText = "${key.addGeneral}";
		$('item_submitAgain').style.display="none";
		flag = "update";

	}
	$('staName').validateUrl = "${ctx}/charge_chargeStandardAction.do?method=checkStanardName";
	sourceValue=$('standardForm').serialize();
	}
</script>
</body>
</html>